import tkinter as tk
from tkinter import messagebox


class application(tk.Frame):
    def __init__(self,master=None):
        self.master=master
        super().__init__(master)
        self.creatWidget()

    def creatWidget(self):
        self.v1=tk.StringVar()
        self.om=tk.OptionMenu(self.master,self.v1,'男','女')
        self.om['width']=1
        self.om.pack()

        self.btn=tk.Button(self.master,text='确定',command=self.pt)
        self.btn.pack()

    def pt(self):
        messagebox.showinfo("sex",f"sex={self.v1.get()}")


window=tk.Tk()
window.title("yudanqu")
window.geometry("400x400+200+50")

app=application(window)
window.mainloop()